﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Dominio;

namespace Persistencia
{
    public class MaestroComanda_Data
    {
        SqlConnection _cn = null;
        SqlCommand _cmd = null;
        SqlDataReader _reader = null;

        public int Data_MaestroComanda_Insert(MaestroComanda _addMaestro)
        {
            using (_cn = new SqlConnection(Helpers.ConexionUtil.ObtenerCadena()))
            {
                using (_cmd = new SqlCommand("USP_MAESTRO_COMANDA_INSERT", _cn))
                {
                    _cn.Open();
                    _cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    _cmd.Parameters.Add("@coMesa", SqlDbType.Int).Value = _addMaestro.Mesa.coMesa;
                    _cmd.Parameters.Add("@coPersona", SqlDbType.Int).Value = _addMaestro.Persona.coPersona;
                    return Convert.ToInt32(_cmd.ExecuteScalar().ToString());
                }
            }
        }

        public int Data_MaestroComanda_Validar(int _codigoMesa)
        {
            using (_cn = new SqlConnection(Helpers.ConexionUtil.ObtenerCadena()))
            {
                using (_cmd = new SqlCommand("USP_MAESTRO_COMANDA_VALIDAR", _cn))
                {
                    _cn.Open();
                    _cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    _cmd.Parameters.Add("@coMesa", SqlDbType.Int).Value = _codigoMesa;
                    return Convert.ToInt32(_cmd.ExecuteScalar().ToString());
                }
            }
        }
    }
}
